import { pget, post, ppostJson } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 获取车队分页
export function getFleetList(query: any) {
	return pget(`${modalApi.customer}/fleet/page`, query)
}

// 搜索车队名称返回车队数据
export function getSelectPage(query: any) {
	return pget(`${modalApi.customer}/fleet/selectPage`, query)
}

// 车队司机统计
export function getFleetDriverStatistics() {
	return pget(`${modalApi.customer}/fleet/topCount`)
}

// 车队新增
export function fleetAdd(data: any) {
	return ppostJson(`${modalApi.customer}/fleet/save`, data)
}
// 车队编辑
export function fleetEdit(data: any) {
	return ppostJson(`${modalApi.customer}/fleet/update`, data)
}

// 删除车队
export function deleteFleet(data: any) {
	return post(`${modalApi.customer}/fleet/remove`, data)
}

// 车队详情
export function getFleetDetail(query: any) {
	return pget(`${modalApi.customer}/fleet/detail`, query)
}

// 获取车队小组列表
export function getFleectGroup(query: any) {
	return pget(`${modalApi.customer}/fleet/car/page/list`, query)
}

// 司官员统计
export function getFleetAdmin(query: any) {
	return pget(`${modalApi.customer}/fleetadmin/count`, query)
}

// 获取司管员列表
export function getFleetAdminList(query: any) {
	return pget(`${modalApi.customer}/fleetadmin/page`, query)
}

// 获取司管员id
export function getFleetAdminId() {
	return pget(`${modalApi.customer}/fleetadmin/getCreateDriverAdminId`)
}

// 添加司官员
export function addFleetAdmin(data: any) {
	return ppostJson(`${modalApi.customer}/fleetadmin/save`, data)
}

// 修改司管员
export function editFleetAdmin(data: any) {
	return ppostJson(`${modalApi.customer}/fleetadmin/update`, data)
}

// 删除司管员
export function deleteFleetAdmin(data: any) {
	return post(`${modalApi.customer}/fleetadmin/remove`, data)
}

// 司管员添加司机
export function fleetAdminAddDriver(data: any) {
	return pget(`${modalApi.customer}/fleetadmin/add/driver`, data)
}

// 车队司机列表 //
export function getFleetDriver(data: any) {
	return pget(`${modalApi.customer}/fleet/driver/list`, data)
}
// 迁移司管员司机
export function fleetAdminMoverDriver(data: any) {
	return pget(`${modalApi.customer}/fleetadmin/mover/driver`, data)
}
/** 获取车队导入错误页列表 */
export function getErrorListPage(query: any) {
	return pget(`${modalApi.customer}/fleet/errorListPage`, query)
}
/** 车队导入数据提交 */
export function getImportData(query: any) {
	return pget(`${modalApi.customer}/fleet/importData`, query)
}
/** 获取司管员导入错误页列表 */
export function getFleetadminErrorListPage(query: any) {
	return pget(`${modalApi.customer}/fleetadmin/errorListPage`, query)
}
/** 司管员导入数据提交 */
export function getFleetadminImportData(query: any) {
	return pget(`${modalApi.customer}/fleetadmin/importData`, query)
}

// 导出车队
export function fleetExport(data: any) {
	return ppostJson(`${modalApi.customer}/fleet/export`, data)
}

// 获取车辆id
export function getCars() {
	return pget(`${modalApi.customer}/fleet/cars`)
}

// 获取车辆id
// export function getOutCarPage(query: any) {
// 	return pget(`${modalApi.carMessage}/vehicle/outCarPage`, query)
// }

// 获取车辆id
export function getOutCarPage(query: any) {
	if (window.apiPrefixUri) {
		return pget(`${window.apiPrefixUri}/mgrApi/car/car/mis/manage/outCarPage`, query)
	}
	return pget(`${modalApi.carMessage}/vehicle/outCarPage`, query)
}
// 新增车辆
export function saveCar(data: any) {
	return ppostJson(`${modalApi.customer}/fleet/save/car`, data)
}

// 移除车队
export function removeCar(query: any) {
	return pget(`${modalApi.customer}/fleet/remove/car`, query)
}

// 历史车队
export function getHistoryFleet(query: any) {
	return pget(`${modalApi.customer}/fleet/car/history/fleet`, query)
}

// 更换车队
export function changeHistoryFleet(query: any) {
	return pget(`${modalApi.customer}/fleet/car/change/fleet`, query)
}

// 车队车辆信息统计
export function getInfoCount(query: any) {
	return pget(`${modalApi.customer}/fleet/infoCount`, query)
}

/** 保存车队车辆导入数据 */
export function getFleetImportData(query?: any) {
	return pget(`${modalApi.customer}/fleet/car/importData`, query)
}

/** 获取导入失败列表 */
export function getFleetErrorListPage(query?: any) {
	return pget(`${modalApi.customer}/fleet/car/errorListPage`, query)
}
/** 验证车队长是否存在 */
// export function getFleetPresent(query?: any) {
// 	return pget(`${modalApi.customer}/fleet/fleetPresent`, query)
// }
export function getFleetPresent(query?: any) {
	if (window.apiPrefixUri) {
		return pget(`${window.apiPrefixUri}/mgrApi/driver-api/fleet/fleetPresent`, query)
	}
	return pget(`${modalApi.customer}/drivers/fleetPresent`, query);
}